#ifndef __Q__ENV__TABLE__HH__
#define __Q__ENV__TABLE__HH__

#include <QtWidgets/qtablewidget.h>
#include "QEnvPrereqs.h"
#include "QEnvTableItem.h"
#include "QDynStore.h"
#include <vector>

class QEnvTable : public QTableWidget
{
	Q_OBJECT

public:
	typedef QDynStore<QEnvTableItem> Store;
	typedef Store::Holder			 ItemHolder;

protected:
	Store mStore;
	QTableWidget * mCustom;
public:
	friend class QEnvTableItem;

	QEnvTable( QWidget * parent = NULL );
	virtual ~QEnvTable( );
	
	void setCustom( QTableWidget * w );
	QTableWidget * custom();
	const QTableWidget* custom() const;

	void grabEnv();
	void saveEnv();

	void setupUi( QTableWidget* table = NULL );
	void setFilter( const String &filter );
	void clearFilters( );
	void clearContents( );
	bool hasItem( const QEnvPath& path ) const;
	ItemHolder& getItem( const QEnvPath& path );
	const ItemHolder getItem( const QEnvPath& path ) const;
	void removeItem( const QEnvPath& path );
	void removeItem( ItemHolder& path );
	ItemHolder addItem( const QEnvPath &path );
	size_t findIndex( const QEnvPath& path ) const;
};

#endif